package SysAccountService

import (
	"github.com/google/uuid"
	"project2/g"
	models "project2/model"
)

func ExitByUserName(userName string) bool {
	var total int64
	g.Db.Model(&models.SysAccount{}).
		Where("user_name =?", userName).
		Count(&total)
	return total > 0
}

func FindUserOneByUserNameAndPassWord(resultUser *models.SysAccount, username string, password string) (bool, string) {
	g.Db.Model(&models.SysAccount{}).
		Where("user_name =?", username).
		Where("pass_word =?", password).
		First(&resultUser)
	if resultUser.Id <= 0 {
		return false, "没有找到用户和密码"
	}

	return true, ""
}

func CreateToken() uuid.UUID {
	return uuid.New()
}
